package io.renren.modules.substation.service.impl;

import io.renren.modules.substation.entity.TInfoAreaInfoEntity;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.substation.dao.TFileInfoDao;
import io.renren.modules.substation.entity.TFileInfoEntity;
import io.renren.modules.substation.service.TFileInfoService;


@Service("tFileInfoService")
public class TFileInfoServiceImpl extends ServiceImpl<TFileInfoDao, TFileInfoEntity> implements TFileInfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<TFileInfoEntity> page = this.page(
                new Query<TFileInfoEntity>().getPage(params),
                new QueryWrapper<TFileInfoEntity>()
        );

        return new PageUtils(page);
    }
    @Override
    public List<TFileInfoEntity> queryFileInfoByCondition(TFileInfoEntity tFileInfoEntity)
    {
        return baseMapper.queryFileInfoByCondition(tFileInfoEntity);
    }

    public TFileInfoEntity getFileInfoByType(List<TFileInfoEntity> list, String purpose){
        TFileInfoEntity ret = new TFileInfoEntity();
        for(TFileInfoEntity o : list){
            if(o.getPurpose().equals(purpose))
            {
                ret= o;
                return  ret;
            }

        }
        return  ret;
    }

    @Override
    public int updateByDevId(TFileInfoEntity tFileInfoEntity){

        return baseMapper.updateByDevId(tFileInfoEntity);
    }

    @Override
    public int updateFileValueByDevData(TFileInfoEntity tFileInfoEntity){

        return baseMapper.updateFileValueByDevData(tFileInfoEntity);
    }

    @Override
    public List<TFileInfoEntity> getFileInfoByDev(List<String> devIds) {
        return baseMapper.selectList(new QueryWrapper<TFileInfoEntity>()
                .in(devIds != null && devIds.size() > 0, "DEV_ID", devIds)
        );
    }

}